import request from '@/utils/request'
import type { ConfigPage, Config } from '@/api/types/config'

export const pageList = (params: {
  current: number,
  size: number,
  name?: string,
  configKey?: string,
  status?: string
}) => {
  return request<ConfigPage>({
    method: 'get',
    url: '/admin/sysConfig/page',
    params
  })
}

export const update = (data: Config) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/sysConfig',
    data
  })
}

export const add = (data: Config) => {
  return request<boolean>({
    method: 'post',
    url: '/admin/sysConfig',
    data
  })
}

export const getById = (id: number) => {
  return request<Config>({
    method: 'get',
    url: '/admin/sysConfig/' + id
  })
}

export const deleteByIds = (ids: number[]) => {
  return request<boolean>({
    method: 'delete',
    url: '/admin/sysConfig/' + String(ids)
  })
}

export const changePwd = (data: {
  oldPwd?: string,
  newPwd?: string,
  newAgainPwd?: string,
}) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/sysConfig/pwd/',
    data
  })
}